package cn.edu.neusoft.maxingxin231.yuejian06.Adapter;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;

import com.squareup.picasso.Picasso;

import java.util.List;

import cn.edu.neusoft.maxingxin231.yuejian06.Activity.DetailActivity;
import cn.edu.neusoft.maxingxin231.yuejian06.Activity.TrainDetailActivity;
import cn.edu.neusoft.maxingxin231.yuejian06.Bean.ActivityBean;

public class ActivityAdapter extends Base2Adapter<ActivityBean> {
    String name,pic,address,data,enroll,cost,aid,price;
    int hotline;

    public ActivityAdapter(Context context, List<ActivityBean> items, int layoutResource) {
        super(context, items, layoutResource);
    }
    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        ActivityBean activityBean = items.get(position);
        if(activityBean==null) return;

        final ClubViewHolder clubViewHolder = (ClubViewHolder) holder;

        final String aid=activityBean.getAid();
        final String name=activityBean.getName();
        final String address=activityBean.getAddress();
        final int hotline=activityBean.getHotline();
        final String pic=activityBean.getPic();
        final String data=activityBean.getData();
        final String enroll=activityBean.getEnroll();
        final String cost=activityBean.getCost();
        final String price=activityBean.getPrice();


        clubViewHolder.c_tv1.setText(name);
        clubViewHolder.c_tv2.setText(address);
        Picasso.with(context).load("http://10.0.2.2:80/yuejian14/public/static/images/"+items.get(position).getPic()).into(clubViewHolder.c_img1);
        clubViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //条目点击事件
                Log.i("TEST","onClick");
                Intent intent = new Intent(context,DetailActivity.class);
                intent.putExtra("aid",aid);
                intent.putExtra("hotline",hotline);
                intent.putExtra("name",name);
                intent.putExtra("address",address);
                intent.putExtra("pic",pic);
                intent.putExtra("data",data);
                intent.putExtra("enroll",enroll);
                intent.putExtra("cost",cost);
                intent.putExtra("price",price);
                context.startActivity(intent);
            }
        });
    }
    public void setList(List<ActivityBean> list){
        this.items = list;
        notifyDataSetChanged();
    }
}
